<template>
  <div class="app-container">
    <el-form
      ref="form"
      size="small"
      :model="form"
      :rules="rules"
      label-width="180px"
	  style="background: rgb(255, 255, 255);width: 550px;margin: 0px 0px 0px 500px;border-radius: 10px;"
    >
      <el-tabs v-model="activeName">

      <!--  <el-tab-pane style="padding-top: 10px" label="基本信息" name="基本信息"> -->
		<el-tab-pane style="padding-top: 10px" label="" name="基本信息">
          <el-row>
            <el-col :span="24">
              <el-form-item label="标题">
                <el-input
                  v-model="form.sys_title"
                  auto-complete="off"
                  clearable
                  placeholder="请输入标题"
				  style="width: 150px;"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="平台图标" prop="logo">
                <ImagesUpload
                  size="small"
                  file-type="image"
                  :image.sync="form.logo"
                />
              </el-form-item>
            </el-col>
          </el-row>
<!--          <el-row>
            <el-col :span="24">
              <el-form-item label="提审版本号">
                <el-input
                  v-model="form.program_version"
                  auto-complete="off"
                  clearable
                  placeholder="提审版本号"
                />
              </el-form-item>
            </el-col>
          </el-row>-->
          <el-row>
            <el-col :span="24">
              <el-form-item label="标语(口号)">
                <el-input
                  v-model="form.SITE_SLOGAN"
                  auto-complete="off"
                  clearable
                  placeholder="标语(口号)"
				  style="width: 150px;"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="保障">
                <el-input
                  v-model="form.securitys"
                  auto-complete="off"
                  clearable
                  placeholder="保障(多条以逗号隔开)"
				  style="width: 150px;"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="发布页是否需要图片">
                <el-radio-group v-model="form.public_is_pic">
                  <el-radio label="0">否</el-radio>
                  <el-radio label="1">是</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="发布页是否需要视频">
                <el-radio-group v-model="form.public_is_video">
                  <el-radio label="0">否</el-radio>
                  <el-radio label="1">是</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="订单确认页面是否需要图片">
                <el-radio-group v-model="form.order_is_pic">
                  <el-radio label="0">否</el-radio>
                  <el-radio label="1">是</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="订单确认页面是否需要视频">
                <el-radio-group v-model="form.order_is_video">
                  <el-radio label="0">否</el-radio>
                  <el-radio label="1">是</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
<!--          <el-row>
            <el-col :span="24">
              <el-form-item label="关键词" prop="keyword">
                <Tag :tag-list.sync="form.keyword" />
              </el-form-item>
            </el-col>
          </el-row>-->
<!--          <el-row>
            <el-col :span="24">
              <el-form-item label="描述" prop="description">
                <el-input
                  v-model="form.description"
                  type="textarea"
                  auto-complete="off"
                  :autosize="{ minRows: 2, maxRows: 4 }"
                  clearable
                  placeholder="请输入站点描述"
				  style="width: 200px;"
                />
              </el-form-item>
            </el-col>
          </el-row>-->
          <el-row>
            <el-col :span="24">
              <el-form-item label="邮箱">
                <el-input
                  v-model="form.EMAIL"
                  auto-complete="off"
                  clearable
                  placeholder="邮箱"
				  style="width: 180px;"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="联系电话">
                <el-input
                  v-model="form.TELEPHONE"
                  auto-complete="off"
                  clearable
                  placeholder="请输入联系电话"
				  style="width: 180px;"
                />
              </el-form-item>
            </el-col>
          </el-row>
<!--          <el-row>
            <el-col :span="24">
              <el-form-item label="首页弹窗客服二维码">
                <ImagesUpload
                  size="small"
                  file-type="image"
                  :image.sync="form.kefuqrcode"
                />
                <div class="help-block">图片尺寸：600x970像素</div>
              </el-form-item>
            </el-col>
          </el-row>-->
          <el-row>
            <el-col :span="24">
              <el-form-item label="百度地图key" prop="bdkey">
                <el-input
                  v-model="form.bdkey"
                  auto-complete="off"
                  clearable
                  placeholder="请输入百度地图key"
				  style="width: 180px;"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="上门费" prop="visit_fee">
                <el-input
                  v-model="form.visit_fee"
                  auto-complete="off"
                  clearable
                  placeholder="请输入上门费"
                />
              </el-form-item>
            </el-col>
          </el-row>
<!--          <el-row>
            <el-col :span="24">
              <el-form-item label="版权信息" prop="copyright">
                <el-input
                  v-model="form.copyright"
                  auto-complete="off"
                  clearable
                  placeholder="请输入版权信息"
				  style="width: 180px;"
                />
              </el-form-item>
            </el-col>
          </el-row>-->
<!--          <el-row>
            <el-col :span="24">
              <el-form-item label="系统状态">
                <el-radio-group v-model="form.sys_status">
                  <el-radio label="0">关闭</el-radio>
                  <el-radio label="1">开启</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>-->

          <el-row>
            <el-col :span="24">
              <el-form-item
                label="默认订单自动结算时间"
                prop="automaticsettlement"
              >

               <!-- <el-input-number
                  v-model="form.automaticsettlement"
                  controls-position="right"
                  style="width: 300px"
                  auto-complete="off"
                  clearable
                  :min="0"
                  placeholder="默认订单自动结算时间"
                /> -->
				<el-input
				   v-model="form.automaticsettlement"

				   style="width: 100px;"
				   auto-complete="off"
				   clearable

				   placeholder="默认订单自动结算时间"
				 />



                <div class="help-block">多少天</div>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="显示商家的默认距离" prop="storedistance">
                <el-input
                  v-model="form.storedistance"
                  controls-position="right"
                  style="width: 100px"
                  auto-complete="off"
                  clearable
                  :min="0"
                  placeholder="请输入显示商家的默认距离"
                />
                <div class="help-block">单位：km</div>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item
                label="显示师傅列表的默认距离"
                prop="technicaldistance"
              >
                <el-input
                  v-model="form.technicaldistance"
                  controls-position="right"
                  style="width: 100px"
                  auto-complete="off"
                  clearable
                  :min="0"
                  placeholder="请输入显示师傅列表的默认距离"
                />
                <div class="help-block">单位：km</div>
              </el-form-item>
            </el-col>
          </el-row>
<!--          <el-row>
            <el-col :span="24">
              <el-form-item label="首页订单播报">
                <el-radio-group v-model="form.is_broadcast">
                  <el-radio label="0">关闭</el-radio>
                  <el-radio label="1">开启</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>-->
<!--          <el-row>
            <el-col :span="24">
              <el-form-item label="商品/服务列表图片比例">
                <el-radio-group v-model="form.listimgproportion">
                  <el-radio label="11">1：1</el-radio>
                  <el-radio label="43">4：3</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>-->
<!--          <el-row>
            <el-col :span="24">
              <el-form-item label="师傅列表图片比例">
                <el-radio-group v-model="form.techlistimgproportion">
                  <el-radio label="11">1：1</el-radio>
                  <el-radio label="43">4：3</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>-->
<!--          <el-row>
            <el-col :span="24">
              <el-form-item label="默认订单状态">
                <el-select
                  v-model="form.default_order_status_id"

                  filterable
                  clearable
                  placeholder="请选择"
                >
                  <el-option
                    v-for="(item, i) in select.order_status"
                    :key="i"
                    :label="item.key"
                    :value="item.val"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>-->
<!--          <el-row>
            <el-col :span="24">
              <el-form-item label="订单已付款状态">
                <el-select
                  v-model="form.paid_order_status_id"

                  filterable
                  clearable
                  placeholder="请选择"
                >
                  <el-option
                    v-for="(item, i) in select.order_status"
                    :key="i"
                    :label="item.key"
                    :value="item.val"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>-->
<!--          <el-row>
            <el-col :span="24">
              <el-form-item label="订单完成状态">
                <el-select
                  v-model="form.complete_order_status_id"

                  filterable
                  clearable
                  placeholder="请选择"
                >
                  <el-option
                    v-for="(item, i) in select.order_status"
                    :key="i"
                    :label="item.key"
                    :value="item.val"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>-->
<!--          <el-row>
            <el-col :span="24">
              <el-form-item label="订单取消状态">
                <el-select
                  v-model="form.cancel_order_status_id"

                  filterable
                  clearable
                  placeholder="请选择"
                >
                  <el-option
                    v-for="(item, i) in select.order_status"
                    :key="i"
                    :label="item.key"
                    :value="item.val"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>-->
          <el-row v-if="sysversion == 'v2'">
            <el-col :span="24">
              <el-form-item label="强制登录">
                <el-radio-group v-model="form.WECHAT_REGISTER_CLOSE">
                  <el-radio label="0">否</el-radio>
                  <el-radio label="1">是</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row v-if="sysversion == 'v2'">
            <el-col :span="24">
              <el-form-item label="注册需要审核">
                <el-radio-group v-model="form.reg_check">
                  <el-radio label="0">否</el-radio>
                  <el-radio label="1">是</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
<!--          <el-row>
            <el-col :span="24">
              <el-form-item label="价格替代的文字" prop="shiftprice">
                <el-input
                  v-model="form.shiftprice"
                  auto-complete="off"
                  clearable
                  placeholder="请输入价格替代的文字"
                />
                <div class="help-block">不显示价格替代的文字</div>
              </el-form-item>
            </el-col>
          </el-row>-->

      <el-row>
        <el-col :span="24">
          <el-form-item label="后台地址" prop="shiftprice">
            <el-input v-model="form.admin_url" style="width: 350px"/>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <el-form-item label="h5地址" prop="shiftprice">
            <el-input v-model="form.h5_url" style="width: 350px"/>
          </el-form-item>
        </el-col>
      </el-row>



        </el-tab-pane>
      </el-tabs>
      <el-form-item>
        <el-button size="small" type="primary" @click="submit"
          >保存设置</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import ImagesUpload from "@/components/common/ImagesUpload.vue";
import Tag from "@/components/common/Tag.vue";
export default {
  name: "Configindex",
  components: {
    ImagesUpload,
    Tag,
  },
  data() {
    return {
      form: {},
      select: {},
      sysversion: "",
      loading: false,
      activeName: "基本信息",
      rules: {},
    };
  },

  mounted() {
    this.$api.post("/config/getField").then((res) => {
      this.select = res.data;
    });
    this.$api.get("/Sysbase/sysversion", this.form).then((res) => {
      this.sysversion = res.data;
    });
    this.$api.post("/config/getInfo").then((res) => {
      this.form = JSON.stringify(res.data) == "[]" ? {} : res.data;
      this.setDefaultVal("keyword");
    });
  },
  methods: {
    submit() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.loading = true;
          this.$api
            .post("/config/update", this.form)
            .then((res) => {
              this.$message({
                message: "操作成功",
                type: "success",
              });
            })
            .catch(() => {
              this.loading = false;
            });
        }
      });
    },
    setDefaultVal(key) {
      if (this.form[key] == null || this.form[key] == "") {
        this.form[key] = [];
      }
    },
  },
};
</script>


<style scoped>
  .el-input {
      position: relative;
      font-size: 14px;
      display: inline-block;
      width: 20%;
  }


  .el-textarea {
      position: relative;
      display: inline-block;
      width: 20%;
      vertical-align: bottom;
      font-size: 14px;
  }

::v-deep  .el-tabs__nav-wrap::after {
      content: "";
      position: absolute;
      left: 0;
      bottom: 0;
      width: 100%;
      height: 0px;
      background-color: #ffffff;
      z-index: 1;
  }

::v-deep  .el-form-item--small .el-form-item__label {
      line-height: 32px;
      margin: 0px 0px 0px 50px;
  }




  ::v-deep .el-tabs__header {
      padding-left: 20px;
      height: 0px;
  }

</style>
